<template>
	<div>
		<div class="pub-title">后台管理</div>
		<ul class="pub-tab">
			<li class="option-list">
				<a href="article.html" class="option on">会员资料</a>
				<!-- <a href="article_classify.html" class="option">分类</a> -->
			</li>
			<li class="tab-block-list">
				<div class="head-tip">
					<select v-model="classify">
						<option value="">全部</option> 
						<option value="1">周易</option>
						<option value="2">占卜</option>
						<option value="3">命理</option>
						<option value="4">风水</option>
						<option value="5">三式</option> 
						<option value="6">其它</option>
					</select>
					<input type="text" class="pub-input" v-model="title" placeholder="资料名称" />
					<input type="text" class="pub-input" v-model="author" placeholder="资料作者" />
					<button class="pub-btn" @click="search">搜索</button>
					<a class="pub-btn" href="memberbook_detail.html?type=add">+ 新增会员资料</a>
				</div>
				<div class="pub-empty" v-show="list.length<1">暂无数据</div>
				<table class="pub-table">
					<tr>
						<th width="80">排序</th>
						<th>资料名称</th>
						<th>资料类别</th>
						<th>作者</th>
						<th>是否显示</th>
						<th>更新时间</th>
						<th width="300">操作</th>
					</tr> 
					<tr v-if="list.length<1">
						<td colspan="7">暂无数据</td>
					</tr>
					<tr class="checkbox" v-for="(v,k) in list">
						<td>{{v.sort}}</td>
						<td>{{v.title}}</td>
						<td>{{options[v.classify]}}</td>
						<td>{{v.author}}</td>
						<td>{{v.isshow==1?"显示":"不显示"}}</td>
						<td>{{$parent.formatDate(v.update_time)}}</td>
						<td> 
							<a :href="'memberbook_detail.html?id='+v._id" class="pub-btn">编辑</a>
							<button class="pub-btn" @click="del(v._id,k)">删除</button>
						</td>
					</tr>
					<!-- <tr class="last">
						<td><input type="checkbox" /> 全选</td>
						<td colspan="5">

						</td>
					</tr> -->

				</table>
			</li>
		</ul>
	</div>
</template>
<script>
	module.exports = {
		data: function() {
			return {
				options: {"1":"周易","2":"占卜","3":"命理","4":"风水","5":"三式","6":"其它"},
				list: [],
				title: "",
				classify:'',
				author:""
			}
		},
		methods: {			
			search(){
				var data="" 
				data+='title='+this.title;
				data+='&classify='+this.classify; 
				data+='&author='+this.author; 
				location.href='memberbook.html?'+data;
			},
			del(id,k){
				UI.alert('确定要删除？','',function(){
					alert(4545)
					//_this.delete(id,k);
				})
			},
			delete(id,k){
				if(!id)return;
				ajax({
					url:"memberbook/del",
					type:'post',
					data:{id:id},
					success:function(res){
						if(res.state==1){							
							_this.list.splice(k,1);
						}else{
							UI.alert(res.msg);
						}
					}
				})
			},
			getList() {
				let data={
					page:query.page?query.page:1,
					title:query.title?query.title:"",
					classify:query.classify?query.classify:"",		
					author:query.author?query.author:"",
					isbackstage:1
				};
				this.classify=data.classify; 
				this.author=data.author;
				this.title=data.title;
				ajax({
					url:"memberbook/list",
					data:data,
					success:function(res){
						if(res.state==1){
							//console.log(res.data.list.length);							
							_this.list=res.data.list;
						}else{
							UI.alert(res.msg);
						}
					}
				})
			}
		},
		created() {
			_this=this;
			this.getList();
		}
	}
</script>
